package com.ux.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.learn.animation.R;

public class ProductPickerFragment extends Fragment implements View.OnClickListener {
	
	View pickButtonCatalog;
	ViewGroup productCatalogTagRoot;
	boolean isProductCatalogShowed = false;
	
	public ProductPickerFragment() {
		// empty constructor
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View rootView = inflater.inflate(R.layout.fragment_product_picker, container, false);
		pickButtonCatalog = rootView.findViewById(R.id.pickButtonCatalog);
		pickButtonCatalog.setOnClickListener(this);
		
		productCatalogTagRoot = (ViewGroup) rootView.findViewById(R.id.productCatalogTagRoot);
		
		rootView.findViewById(R.id.tagButton0).setOnClickListener(this);
		rootView.findViewById(R.id.tagButton1).setOnClickListener(this);
		rootView.findViewById(R.id.tagButton2).setOnClickListener(this);
		rootView.findViewById(R.id.tagButton3).setOnClickListener(this);
		rootView.findViewById(R.id.tagButton4).setOnClickListener(this);
		rootView.findViewById(R.id.tagButton5).setOnClickListener(this);
		rootView.findViewById(R.id.tagButton6).setOnClickListener(this);
		return rootView;
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.pickButtonCatalog:
			showProductCatalogTag();
			break;
			
		case R.id.tagButton0:
		case R.id.tagButton1:
		case R.id.tagButton2:
		case R.id.tagButton3:
		case R.id.tagButton4:
		case R.id.tagButton5:
		case R.id.tagButton6:
			showProductCatalogTag();
			break;

		default:
			break;
		}
	}

	private void showProductCatalogTag() {
		if (isProductCatalogShowed) {
			productCatalogTagRoot.setVisibility(View.GONE);
		} else {
			productCatalogTagRoot.setVisibility(View.VISIBLE);
		}
		isProductCatalogShowed = !isProductCatalogShowed;
	}
	
}
